package be.pluyckx.batteryprogress.logging;

import java.util.Collection;
import java.util.Iterator;

/**
 * Created by Philip Luyckx on 17/08/13.
 */
public class LogUtils {
  public static String dumpCollection(Collection collection, String name) {
    StringBuilder sb = new StringBuilder();

    sb.append(name);
    sb.append('\n');
    if (collection.size() > 0) {
      Iterator<Object> iterator = collection.iterator();
      sb.append('\t');
      sb.append(iterator.next().toString());

      while (iterator.hasNext()) {
        sb.append("\n\t");
        sb.append(iterator.next().toString());
      }
    } else {
      sb.append("\tEmpty");
    }

    return sb.toString();
  }
}
